// 多级路由转一级路由
export function formatRoutes(routes, init = []) {
  if(Array.isArray(routes)) {
    for(let i =0; i < routes.length; i++) {
      const { children } = routes[i]
      if(children) {
        formatRoutes(routes[i], init)
      }else {
        init.push(routes[i])
      }
    }
  } else if(routes.children && Array.isArray(routes.children)) {
    const {children} = routes
    init.push(routes)
    formatRoutes(children, init)
    routes.children = null
  }
  return init
}

